import pygame, tile, random
from pygame.locals import *

from tile import * 

class Mob(pygame.sprite.Sprite):
    """Represents one "person" in the game -- the player, a TA, Markowsky, etc"""
    def __init__(self, image, initialPosition, name="Unnamed Mob", isAI=False, moves=None, gpa=4.0, energy=10):
        """Creates a mob with the specified parameters"""
        pygame.sprite.Sprite.__init__(self)
        self.image = image
        self.rect = self.image.get_rect()
        self.rect.topleft = initialPosition
        self.isAI = isAI
        self.moveGoal = [0, 0]
        self.name = name
        self.energy = energy
        self.gpa = gpa
        self.points = 0
        self.power = 1

        if moves is not None:
            self.moves = moves
        else:
            self.moves = [Move("Test Move 1", 1), Move("Test Move 2", 2), Move("Test Move 3", 3)]

    def move(self, tilesX, tilesY):
        """Sets the mob's movegoal as delta x and delta y tiles in each direction. Does not ACTUALLY move the mob; it's just a request to the MobManager that this mob move on the next turn."""
        self.moveGoal = [tilesX, tilesY]
        
    def update(self):
        """Used to hold some AI stuff. RIP AI stuff."""
        #wandering AI
        #if self.isAI:
        #    choice = random.randint(0, 2)
        #    if choice == 0:
        #        return #do nothing
        #    if choice == 1:
        #        self.move(random.choice([-1, 1]), 0)
        #    if choice == 2:
        #        self.move(0, random.choice([-1, 1]))
        pass
    
    def getTileCoords(self):
        """Returns the tile coordinates that the mob is currently located at as [x, y]"""
        return [self.rect.topleft[0] / TILESIZE, self.rect.topleft[1] / TILESIZE]

#a wrapper for "moves"
class Move:
    """Wrapper class to represent a "move" (studying, homework, whichever)"""
    def __init__(self, name, power):
        self.name = name
        self.power = power
